<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="ssm" uri="http://ssm.elangzhi.com/jsp/tag/functions" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%--
Created by GaoXiang
Date: 2020-10-10 13:34:00 星期六
Version: 1.0
用户编辑页面
--%>

<div class="portlet light" >
    <div class="portlet-body form">
        <!-- BEGIN FORM-->
        <form action="#" class="form-horizontal" id="edit-module">
            <div class="form-body">

                <div class="row">
                    <div class="col-md-6 hide">
                        <div class="form-group">
                            <label class="control-label col-md-3">ID</label>
                            <div class="col-md-9">
                                <input type="text" class="form-control" name="id" value="${data.id}" placeholder="默认生成，ID">
                            </div>
                        </div>
                    </div>

                    <div class="col-md-6">
                        <div class="form-group">
                            <label class="control-label col-md-3">部门</label>
                            <div class="col-md-9">
                                <select class="form-control" required name="orgId">
                                    <option value="" selected>请选择部门</option>
                                    <c:forEach items="${departmentList}" var="item">
                                        <option value="${item.id}" <c:if test="${data.orgId == item.id}">selected</c:if>>${item.name}</option>
                                    </c:forEach>
                                </select>
                            </div>
                        </div>
                    </div>

                    <div class="col-md-6">
                        <div class="form-group">
                            <label class="control-label col-md-3">人员姓名</label>
                            <div class="col-md-9">
                                <input type="text" class="form-control" maxlength="100" required name="name" value="${data.name}" placeholder="请输入人员姓名">
                            </div>
                        </div>
                    </div>

                    <div class="col-md-6">
                        <div class="form-group">
                            <label class="control-label col-md-3">人员工号</label>
                            <div class="col-md-9">
                                <input type="text" class="form-control" maxlength="50" required name="number" value="${data.number}" placeholder="请输入人员工号">
                            </div>
                        </div>
                    </div>

                    <div class="col-md-6">
                        <div class="form-group">
                            <label class="control-label col-md-3">性别</label>
                            <div class="col-md-9">
                                <select class="form-control" name="sex">
                                    <option value="">请选择性别</option>
                                    <option value="男" <c:if test="${data.sex == '男'}">selected</c:if>>男</option>
                                    <option value="女" <c:if test="${data.sex == '女'}">selected</c:if>>女</option>
                                </select>
                            </div>
                        </div>
                    </div>

                    <div class="col-md-6">
                        <div class="form-group">
                            <label class="control-label col-md-3">手机号</label>
                            <div class="col-md-9">
                                <input type="text" class="form-control" required name="phone"  maxlength="20" value="${data.phone}" placeholder="请填写人员手机号">
                            </div>
                        </div>
                    </div>

             <%--       <div class="col-md-6">
                        <div class="form-group">
                            <label class="control-label col-md-3">headImg</label>
                            <div class="col-md-9">
                                <input type="text" class="form-control" required name="headImg" value="${data.headImg}" placeholder="headImg">
                            </div>
                        </div>
                    </div>--%>

                    <div class="col-md-6">
                        <div class="form-group">
                            <label class="control-label col-md-3">职位</label>
                            <div class="col-md-9">
                                <input type="text" class="form-control" required name="position"  maxlength="20" value="${data.position}" placeholder="请填写人员职位">
                            </div>
                        </div>
                    </div>

                </div>
            </div>
            <div class="form-actions">
                <div class="row">
                    <div class="col-md-6">
                        <div class="row">
                            <div class="col-md-offset-3 col-md-9">
                                <button type="button" class="btn green" onclick="edit();">修改用户</button>
                                <button type="button" class="btn default" onclick="layer.close(layer_editModule);">取消</button>
                            </div>
                        </div>
                    </div>
                    <div class="col-md-6"> </div>
                </div>
            </div>
        </form>
        <!-- END FORM-->
    </div>
</div>
<!-- script 开始 -->
<script>

    $(function(){
        //初始化页面
        initPage();
    });

    /**
     * 保存编辑的用户
     */
    function edit(){
        var param = tools.formParams("edit-module");
        if(tools.valid("edit-module")){
            tools.post("/users/update",param,function(data){
                if(data.success){
                    layer.msg('用户修改成功', {icon: 1,time:1000},function(){
                        //刷新列表页面
                        toPage(null);
                        //关闭弹窗
                        layer.close(layer_editModule);
                    });
                }else{
                    tools.errorTip(data.code,data.data);
                }
            });
        }
    }
</script>
<!-- script 结束 -->